#pragma once


const UINT UM_FTP_SEND = RegisterWindowMessage(_T("UM_FTP_SEND"));
const UINT UM_FTP_ERROR = RegisterWindowMessage(_T("UM_FTP_ERROR"));
const UINT UM_FTP_COMPLETE = RegisterWindowMessage(_T("UM_FTP_COMPLETE"));


class FtpClient
{

public:

	FtpClient(HWND hWnd);
	~FtpClient(void);

	void DisConnect();
	bool IsRunning() {return m_isRunning;}

	bool UpLoad(const TCHAR* tServerInfo, const TCHAR* tFilePath, INT64 nFileStartSize);
	bool UpLoadTrick(const TCHAR* tFilePath, INT64 nFileStartSize);	


	bool FileTrans();
	bool FileTransTrick();

	static UINT WINAPI ProcFileTrans(LPVOID pParam);
	static UINT WINAPI ProcFileTransTrick(LPVOID pParam);


protected:

	HWND m_hMainWindow;

	HANDLE m_hFile;
	HANDLE m_hThread;
	HANDLE m_hEndEvent;

	SOCKET m_Sock;

	CString m_sIP;
	INT m_iPort;

	CString m_sFilePath;
	INT64 m_nFileTransStart;
	INT64 m_nFileSize;;

	bool m_isRunning;

	CString m_sError;

	bool FileCheckOpen();
	bool ConnectFileServer(CString sIP, int iPort);
	bool SendProc(INT64& iCurrent, INT& iReport);
};

